<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('本厂库存列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="pName"/>
                        </li>
                        <li class="select-time">
                            <label>创建时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:stock:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
         var prefix = ctx + "system/building";
         var prefixs = ctx + "ruoyi/stock";

         $(function() {
             var options = {
                 url: prefix + "/list",
                 modalName:"",
                 exportUrl: prefixs + "/export",
                 showSearch: false,
                 showRefresh: false,
                 showToggle: false,
                 showColumns: false,
                 detailView: true,
                 onExpandRow: function (index, row, $building) {
                     initChildTable(index, row, $building);
                 },

                 columns: [
                     {
                         field: 'pId',
                         title: '项目id',
                         visible: false
                     },
                     {
                         field: 'pName',
                         title: '项目名称'
                     },
                     {
                         field: 'pTime',
                         title: '项目日期'
                     },
                     {
                         field: 'pFounder',
                         title: '项目经理'
                     },
                 ]
             };
             $.table.init(options);
         });

         initChildTable = function (index, row, $building) {
             var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
             $(childTable).bootstrapTable({
                 url: prefixs  + "/list",
                 method: 'post',
                 sidePagination: "server",
                 contentType: "application/x-www-form-urlencoded",
                 queryParams: {
                     sid:row.pId
                 },
                 columns: [
                     {
                         field: 'id',
                         title: '材料id',
                         visible: false
                     },
                     {
                         field: 'tName',
                         title: '材料类型'
                     },
                     {
                         field: 'tNum',
                         title: '材料数量',
                     },
                     {
                         field: 'tId',
                         title: '项目外键',
                         visible: false
                     },

                 ]
             });
         };

     </script>
</body>
</html>